import React, { useRef } from 'react';
import flv from 'flv.js';
export default () => {
    const videoRef = useRef<HTMLVideoElement>(null);
    const onChange = (e: any) => {
        if (!videoRef.current) return;
        videoRef.current.innerHTML = '';
        console.log(e.target.files[0]);
        const file: File = e.target.files[0];
        const srcUrl = window.URL.createObjectURL(file);
        if (flv.isSupported()) {
            var videoElement = document.getElementById('videoElement');
            var flvPlayer = flv.createPlayer({
                type: 'flv',
                url: srcUrl,
            });
            flvPlayer.attachMediaElement(videoRef.current);
            flvPlayer.load();
            flvPlayer.play();
        }
    };
    return (
        <div>
            <input type="file" onChange={onChange} accept=".flv" />
            <video ref={videoRef} id="video" controls muted/>
        </div>
    );
};
